package cn.sh.library.mgts.common;

import java.util.HashMap;
import java.util.Map;

public class Constant {
	public static final String PATH_TO_GRAPH = "_source.@graph";

	public static final String BIB_RELATION_INDEX_NAME = "hor_bib_relation";
	public static final String ITEM_LOCATION_INDEX_NAME = "hor_item_location";
	public static final String ITEM_COLLECTION_INDEX_NAME = "hor_item_collection";
	public static final String ITEM_ITYPE_INDEX_NAME = "hor_item_itype";
	public static final String BIB_INDEX_NAME = "bib_horizon";
	public static final String BIB_HORIZON_USER = "bib_horizon_user";
	public static final String BIB_HORIZON_BANNEDWORDS = "bib_horizon_bannedwords";
	public static final String DATA_SYNC_LOG_INDEX = "data_sync_log";
	public static final String BLOCK_BIBS_INDEX = "block_bibs";
	public static final String PLACE_INDEX = "shl_place";
	
	public static final String MGTS_INSTANCE_INDEX = "shlmgts_instance";
	public static final String MGTS_CLASS_INDEX = "shlmgts_class";

	
	public static final String BIB_HORIZON_CAN_INDEX = "0";
	public static final String BIB_HORIZON_CANT_INDEX = "1";
	
	public static final String  BIB_HORIZON_RELATION_USMARC = "USMARC";
	public static final String  BIB_HORIZON_RELATION_CNMARC = "CNMARC";

	
	public static final String BIB_HORIZON_LOCATION = "location";
	public static final String BIB_HORIZON_COLLECTION = "collection";
	
	public static final String BIB_INDEX_ID_PREFIX = "bib_";
	public static final String ITEM_INDEX_ID_PREFIX = "item_";
	public static final String JOIN_RELATION_PARENT_JSON = "{\"name\":\"bib\"}";
	public static final String JOIN_RELATION_CHILD_JSON = "{\"name\":\"item\", \"parent\":\"%1$s\"}";

	public static final String BIB_INDEX_JSON = "{\"_index\":\"bib_horizon\", \"_type\":\"doc\",\"_id\":\"%1$s\"}";
	public static final String BIB_DELETE_JSON = "{\"_index\":\"bib_horizon\", \"_type\":\"doc\",\"_id\":\"%1$s\"}";

	public static final String LOGGER_BULK_NAME = "bulklog";
	public static final String LOGGER_ACCESS_NAME = "accesslog";

	// 返回标识
	public static final String RESULT_SUCCESS = "0";// 成功
	public static final String RESULT_ERROR = "1";// 失败

	public static final String ERROR_CODE = "errorCode";
	public static final String ERROR_MESSAGE = "errorMessage";

	public static final String FIELD_RESULT_PAGER = "pager";
	public static final String FIELD_RESULT_DATAS = "datas";

	public static final String PATH_TO_HITS = "hits.hits";
	
	public static final String BIB_DEFAULT_TYPE = "doc";
	public static final String MGTS_DEFAULT_TYPE = "doc";

	public static final String DATETIME_FORMAT = "yyyy-MM-dd' 'HH:mm:ss.SSS";
	
	public static final String BIB_HORIZON_SETTING = "{\r\n" + 
			"		\"index\": {\r\n" + 
			"			\"number_of_shards\": 5,\r\n" + 
			"			\"number_of_replicas\": 1\r\n" + 
			"		},\r\n" + 
			"		\"analysis\": {\r\n" + 
			"			\"normalizer\": {\r\n" + 
			"				\"lc_normalizer\": {\r\n" + 
			"					\"type\": \"custom\",\r\n" + 
			"					\"char_filter\": [],\r\n" + 
			"					\"filter\": [\r\n" + 
			"						\"lowercase\",\r\n" + 
			"						\"asciifolding\"\r\n" + 
			"					]\r\n" + 
			"				}\r\n" + 
			"			},\r\n" + 
			"			\"analyzer\": {\r\n" + 
			"				\"escape_dash_analyzer\": {\r\n" + 
			"					\"tokenizer\": \"standard\",\r\n" + 
			"					\"char_filter\": [\r\n" + 
			"						\"escape_dash_filter\"\r\n" + 
			"					],\r\n" + 
			"					\"filter\": [\r\n" + 
			"						\"lowercase\"\r\n" + 
			"					]\r\n" + 
			"				}\r\n" + 
			"			},\r\n" + 
			"			\"char_filter\": {\r\n" + 
			"				\"escape_dash_filter\": {\r\n" + 
			"					\"type\": \"pattern_replace\",\r\n" + 
			"					\"pattern\": \"-\",\r\n" + 
			"					\"replacement\": \"\"\r\n" + 
			"				}\r\n" + 
			"			}\r\n" + 
			"		}\r\n" + 
			"	}";
	public static final String BIB_HORIZON_MAPPING = "{\r\n" + 
			"		\"properties\": {\r\n" + 
			"			\"location\": {\r\n" + 
			"				\"type\": \"text\",\r\n" + 
			"				\"fields\": {\r\n" + 
			"					\"keyword\": {\r\n" + 
			"						\"type\": \"keyword\",\r\n" + 
			"						\"normalizer\": \"lc_normalizer\"\r\n" + 
			"					}\r\n" + 
			"				}\r\n" + 
			"			},\r\n" + 
			"			\"collection\": {\r\n" + 
			"				\"type\": \"text\",\r\n" + 
			"				\"fields\": {\r\n" + 
			"					\"keyword\": {\r\n" + 
			"						\"type\": \"keyword\",\r\n" + 
			"						\"normalizer\": \"lc_normalizer\"\r\n" + 
			"					}\r\n" + 
			"				}\r\n" + 
			"			},\r\n" + 
			"			\"search\": {\r\n" + 
			"				\"properties\": {\r\n" + 
			"					\"clc_term\": {\r\n" + 
			"						\"type\": \"text\",\r\n" + 
			"						\"fields\": {\r\n" + 
			"							\"keyword\": {\r\n" + 
			"								\"type\": \"keyword\"\r\n" + 
			"							}\r\n" + 
			"						},\r\n" + 
			"						\"analyzer\": \"escape_dash_analyzer\"\r\n" + 
			"					},\r\n" + 
			"					\"isbn_term\": {\r\n" + 
			"						\"type\": \"text\",\r\n" + 
			"						\"fields\": {\r\n" + 
			"							\"keyword\": {\r\n" + 
			"								\"type\": \"keyword\"\r\n" + 
			"							}\r\n" + 
			"						},\r\n" + 
			"						\"analyzer\": \"escape_dash_analyzer\"\r\n" + 
			"					},\r\n" + 
			"					\"ordern_term\": {\r\n" + 
			"						\"type\": \"text\",\r\n" + 
			"						\"fields\": {\r\n" + 
			"							\"keyword\": {\r\n" + 
			"								\"type\": \"keyword\"\r\n" + 
			"							}\r\n" + 
			"						},\r\n" + 
			"						\"analyzer\": \"escape_dash_analyzer\"\r\n" + 
			"					}\r\n" + 
			"				}\r\n" + 
			"			}\r\n" + 
			"		}\r\n" + 
			"	}";
	//用户结构
	public static final String BIB_HORIZON_USER_MAPPING = "{\r\n" + 
			"				\"properties\": {\r\n" + 
			"                    \"userId\": {\r\n" + 
			"						\"type\": \"keyword\"\r\n" + 
			"					},\r\n" + 
			"                    \"userName\": {\r\n" + 
			"						\"type\": \"text\"\r\n" + 
			"					},\r\n" + 
			"                    \"userPwd\": {\r\n" + 
			"						\"type\": \"text\"\r\n" + 
			"					}\r\n" + 
			"				}\r\n" + 
			"			}";
	public static final String BIB_HORIZON_USER_SETTING = " {\r\n" + 
			"				\"index\" : {\r\n" + 
			"					\"number_of_shards\" : 1,     \r\n" + 
			"					\"number_of_replicas\" : 1    \r\n" + 
			"				}\r\n" + 
			"			}";
	
	public static final String BIB_HORIZON_BWORDS_MAPPING = "{\r\n" + 
			"				\"properties\": {\r\n" + 
			"                    \"words\": {\r\n" + 
			"						\"type\": \"keyword\"\r\n" + 
			"					}\r\n" + 
			"				}\r\n" + 
			"			}";
	public static final String BIB_HORIZON_BWORDS_SETTING = "{\r\n" + 
			"				\"index\" : {\r\n" + 
			"					\"number_of_shards\" : 1,    \r\n" + 
			"					\"number_of_replicas\" : 1   \r\n" + 
			"				}\r\n" + 
			"			}";

	public static final String CONSTRUCT_CONTEXT = "{\"@context\":{\"@vocab\": \"http://www.library.sh.cn/\", \"@language\": \"en\"}}";
	public static final String CONSTRUCT_FRAME = "{\"@context\":{\"@vocab\":\"http://www.library.sh.cn/\"},\"@type\":\"Work\",\"place\":{\"@type\":\"Place\"},\"hasInstance\":{\"@type\":\"Instance\",\"hasItem\":{\"@type\":\"Item\",\"contains\":{\"@type\":\"Organization\"}}}}";
	public static final String CONSTRUCT_TEST_FRAME = "{\"@context\":{\"@vocab\":\"http://www.library.sh.cn/\"},\"@omitGraph\":true,\"@type\":\"Person\",\"temporal\":{\"@type\":\"Temporal\"},\"nationality\":{\"@type\":\"Category\"},\"familyName\":{\"@type\":\"FamilyName\"},\"nation\":{\"@type\":\"Category\"},\"nativePlace\":{\"@type\":\"Place\"},\"officialPosition_position\":{\"@type\":\"OfficialPosition \"}}";

	public static final String LOGGER_SYNC = "synclog";
	public static final String LOGGER_SYNCERR = "syncErrlog";
	public static final String CONSTRUCT_MGTS_FRAME = "{\"@context\":{\"@vocab\":\"http://www.library.sh.cn/\"},\"@omitGraph\":true,\"@type\":\"Instance\",\"title\":{\"@type\":\"Title\"},\"variantTitle\":{\"@type\":\"VariantTitle\"},\"parallelTitle\":{\"@type\":\"ParallelTitle\"},\"instanceContribution\":{\"@type\":\"instanceContribution\"},\"workContribution\":{\"@type\":\"workContribution\"},\"provisionActivity\":{\"@type\":\"ProvisionActivity\"},\"production\":{\"@type\":\"Production\"},\"publication\":{\"@type\":\"Publication\"},\"note\":{\"@type\":\"Note\"},\"classification\":{\"@type\":\"Classification\"},\"work\":{\"@type\":\"Work\"},\"instancePerson\":{\"@type\":\"InstancePerson\"},\"workPerson\":{\"@type\":\"WorkPerson\"},\"item\":{\"@type\":\"Item\"}}";

	public static void main(String[] args) {
		System.out.println(CONSTRUCT_MGTS_FRAME);
	}

	//表达式检索映射关系 
	public static final Map<String, String> EXPR_FIELD_MAP = new HashMap<String, String>() {
		{
			put("ALL", "title.label.@value,contribution.personName.@value,provisionActivity.proPlace.@value,provisionActivity.proOrganization.@value,provisionActivity.proDate,seriesLabel,item.shelfMark,workUri.workSubject");
			put("TI", "title.label.@value");
			put("CO", "contribution.personName.@value");
			put("ED", "provisionActivity.proOrganization.@value");
			put("PP", "provisionActivity.proPlace.@value");
			put("IS", "provisionActivity.proDate");
			put("PL", "@graph.plateFrame.@value,@graph.charsNumberPerLine.@value,@graph.fishTail.@value,@graph.elephantNose.@value");
			put("HO", "item.shelfMark");
			put("TM", "title.label.@value");// 题名
			put("CS", "seriesLabel");// 从事
			put("SSH", "item.shelfMark");// 索书号
			put("ZRZ", "contribution.personName.@value");// 责任者
			put("CBD", "provisionActivity.proPlace.@value");// 出版地
			put("CBJG", "provisionActivity.proOrganization.@value");// 出版机构
			put("YEAR", "provisionActivity.proDate");// 出版年
			put("ZTC", "complexSubject.labelConcat");// 主题词
			put("FXJG", "publication.pubOrganization.@value");// 出版发行机构

			// 分类
			put("FL", "classification.level");
			// 分面 出版年 出版社 出版地 责任者 分类 关键词(work下主题词)
			put("FACET_YEAR", "provisionActivity.proDate");
			put("FACET_PUBLISHER", "provisionActivity.proOrganization.@value");
			put("FACET_PLACE", "provisionActivity.proPlace.@value");
			put("FACET_PERSON", "contribution.personName.@value");
			put("FACET_CLASSES", "classfacet");
			put("FACET_SUBJECT", "complexSubject.labelConcat");

			// workDetail
			put("WORK", "workUri.@id");

			// 地图检索
			put("LONG", "long");
			put("LAT", "lat");
		}
	};

}
